﻿@model XW.Data.SysRole
@{
}

@section css {
    <style>
        body { background-color: #ffffff; }
    </style>
}
<div class="layui-form layuimini-form layui-layout-admin">
    <input type="hidden" name="id" value="@Model.Id" />
    <div class="layui-form-item">
        <label class="layui-form-label required" for="Name">角色名</label>
        <div class="layui-input-block">
            <input id="Name" type="text" name="Name" lay-reqtext="角色名不能为空" lay-verify="required" placeholder="请输入角色名" value="@Model.Name" class="layui-input">
            <tip>填写角色的名称。</tip>
        </div>
    </div>
  

    <div class="layui-form-item">
        <div class="layui-input-block">
            <div class="layui-footer">
                <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
            </div>
        </div>
    </div>
</div>
@section js {

    <script>
        var baseUrl = '@(Url.Content("~/"))';
        layui.use(['form'], function () {
            var form = layui.form,
                layer = layui.layer,
                $ = layui.$;

            //监听提交
            form.on('submit(saveBtn)', function (data) {
                var loadIndex = layer.load(3);
                $.ajax({
                    url: '@(Url.Content("~/sys/role/save"))',
                    data: data.field,
                    method: 'post',
                    success: function (d) {
                        // console.log(d);
                        // l.destroy();
                        layer.close(loadIndex);
                        if (d.resultCode == "200") {
                            var l = parent.layer;
                            l.msg('保存成功');
                            var iframeIndex = l.getFrameIndex(window.name);
                            l.close(iframeIndex);
                        } else {

                            layer.msg(d.message);

                        }
                        // alert(d)
                    },
                    error: function (e) {
                        // console.log(e);
                        layer.close(loadIndex);
                    }
                });

                // var index = layer.alert(JSON.stringify(data.field), {
                //     title: '最终的提交信息'
                // }, function () {

                //     关闭弹出层
                //     layer.close(index);

                //     var iframeIndex = parent.layer.getFrameIndex(window.name);
                //     parent.layer.close(iframeIndex);

                // });

                return false;
            });

        });
    </script>
} 